import React from "react";
import { useSelector, useDispatch } from "react-redux";
import { Button, NavBar } from "react-vant";
import { changeState } from "../../store/personList";
import { useNavigate } from "react-router-dom";
const PersonList = () => {
  const list = useSelector((state) => state.personList.list);
  const dispatch = useDispatch();
  const navigate = useNavigate()
  console.log(list);
  return (
    <div>
      <NavBar title="选择乘车人"></NavBar>

      <div>
        {list.map((v, i) => {
          return (
            <div key={i}>
              <input type="checkbox" checked={v.state} onClick={() => dispatch(changeState(v))}/>
              {v.name}-{v.code}
            </div>
          );
        })}
      </div>

      <Button type="primary" block onClick={() => navigate(-1)}>
        确定
      </Button>
    </div>
  );
};

export default PersonList;
